﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Microsoft.Samples.SqlServer.Common.Forms;

namespace WorkflowDesigner
{
  static class Program
  {
        static DesignerForm designerForm = null;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {  
         
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {      
                designerForm = new DesignerForm();
                designerForm.splitContainer.Panel2Collapsed = false;
                designerForm.runButton.Click += runButton_Click;
               
                Application.Run(designerForm);
            }

            finally
            {
                if (designerForm != null)
                    designerForm.Dispose();
            }
        }

        static void runButton_Click(object sender, EventArgs e)
        {
            SampleActivity sampleActivity = new SampleActivity(designerForm.workflowActivitiesControl);

            var handleInput = new Dictionary<String, Object>
            {
                {"Handle", System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle}
            };

            sampleActivity.Run(designerForm.WorkflowPath, handleInput);
        }
    }
}
